package com.company.web;

import com.company.api.UserServiceI;
import com.company.dto.MembersLoginCmd;
import com.company.common.dto.R;
import com.company.dto.data.LoginInfoDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

@RestController
@Tag(name = "会员相关接口")
@RequestMapping("/api/v1/members")
public class MembersController {
    private final UserServiceI userService;

    public MembersController(UserServiceI userService) {
        this.userService = userService;
    }

    @Operation(summary = "会员登录")
    @PostMapping("/sign-in")
    public R<LoginInfoDTO> signIn(@RequestBody MembersLoginCmd cmd) {
        return R.data(userService.loginMembers(cmd));
    }
    @Operation(summary = "刷新token")
    @PostMapping("/refresh-token")
    public R<LoginInfoDTO> refreshToken(String refreshToken) {
        return R.data(userService.refreshToken(refreshToken));
    }
    @Operation(summary = "获取手机验证码")
    @GetMapping("/mobile-verify-code")
    public R<Void> getMobileVerifyCode(String mobile) {
        userService.getMobileVerifyCode(mobile);
        return R.data(null);
    }

    @Operation(summary = "获取手机验证码")
    @GetMapping("/email-verify-code")
    public R<Void> getEmailVerifyCode(String email) {
        userService.getEmailVerifyCode(email);
        return R.data(null);
    }

}
